home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
share
/
catman
/
p_man
/
cat3
/
streadimageheader.z
/
streadimageheader
Wrap
Text File
|
1996-05-06
|
9KB
|
199 lines
SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333)))) IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333))))
NNNNAAAAMMMMEEEE
STReadImageHeader, STWriteImageHeader - read/write STIFF image header
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
####iiiinnnncccclllluuuuddddeeee <<<<ssssttttiiiiffffffff....hhhh>>>>
iiiinnnntttt SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((SSSSTTTTSSSSttttrrrreeeeaaaammmm ****sssstttt,,,, SSSSTTTTIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr ****hhhhdddd))));;;;
iiiinnnntttt SSSSTTTTWWWWrrrriiiitttteeeeIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((SSSSTTTTSSSSttttrrrreeeeaaaammmm ****sssstttt,,,, SSSSTTTTIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr ****hhhhdddd,,,,
iiiinnnntttt llllaaaasssstttt))));;;;
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
Before an image is read from a STIFF stream an image header must be
obtained from the stream. Similarly, before an image is written to a
STIFF stream an image header structure must be filled in and written to
the stream. The functions _S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r and _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r assist
with these image header tasks.
_S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r reads the image header information from the stream
specified by _s_t and places the information in the image header structure
specified by _h_d. _s_t must point to a STIFF stream open for reading.
Following a successful call to _S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r, the function _S_T_R_e_a_d can
be called to read the actual image data. The amount of image data
available can be found in the _S_T_I_m_a_g_e_H_e_a_d_e_r structure. In addition,
following a successful call to _S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r the TIFF tag list read
from the STIFF stream can be queried using the _S_T_G_e_t_T_a_g function.
After the last image has been read from a STIFF stream, the next call to
_S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r will return -1, and _S_T_e_r_r_n_o will be set to SSSSTTTTEEEEEEEEOOOOFFFF (see
below).
_S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r writes the image header to the STIFF stream specified
by _s_t. Before a call to _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r any caller specific TIFF tags
should be added to the output tag list using the _S_T_A_d_d_T_a_g function.
Make sure that all fields of the SSSSTTTTIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr structure passed to
_S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r contain reasonable values; otherwise, garbage will be
written into the STIFF stream.
Following a successful call to _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r the actual image data
can be written to the stream using _S_T_W_r_i_t_e. The amount of image data that
must be written to the stream is specified in the _S_T_I_m_a_g_e_H_e_a_d_e_r
structure. Note that following a successful call to _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r
the output TIFF tag list is cleared.
The _l_a_s_t parameter to _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r should be set to 1 if this is to
be the last image written to this stream. In this case,
_S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r will store a value in the stream to indicate to
readers that this is the last image. _l_a_s_t should be set to 0 if more
images are to be written after this one, in which case _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r
calculates the offset of where the next image will start and stores that
PPPPaaaaggggeeee 1111
SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333)))) IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333))))
location in the stream.
The _S_T_I_m_a_g_e_H_e_a_d_e_r structure is defined as follows.
typedef struct tag_imghdr {
unsigned long width, height; /* Dimensions in pixels */
unsigned short bitsPerSample; /* Bits per channel */
unsigned short samplesPerPixel; /* # of color channels */
unsigned long imgbytes; /* Bytes of image data */
STType type; /* Image data type */
STPlane plane; /* Planar configuration */
} STImageHeader;
TTTTIIIIFFFFFFFF TTTTAAAAGGGGSSSS UUUUSSSSEEEEDDDD
The _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r function will write the TIFF tags listed below
into the STIFF stream. Caller specific tags would be output in addition
to the tags listed. The tags are expressed in terms of their names in the
header file _s_t_i_f_f._h
STBitsPerSample
STImageLength
STImageWidth
STPhotometricInterpretation
STPlanarConfiguration
STSamplesPerPixel
STStripByteCounts
STStripOffsets
RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
Both _S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r and _S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r return 0 if execution was
successful. -1 is returned and _S_T_e_r_r_n_o is set if an execution error has
occurred.
EEEEXXXXEEEECCCCUUUUTTTTIIIIOOOONNNN EEEERRRRRRRROOOORRRR CCCCOOOODDDDEEEESSSS
_S_T_R_e_a_d_I_m_a_g_e_H_e_a_d_e_r will fail under the following circumstances.
STEBADTAG Invalid TIFF tag.
STENOMEM Out of memory.
STEREADFROMWRITE Attempt to read from a write stream.
STESYSCALL System call failed.
STENEEDSEEK Operation requires seeking on a stream.
STEEOF End of stream.
_S_T_W_r_i_t_e_I_m_a_g_e_H_e_a_d_e_r will fail under the following circumstances.
PPPPaaaaggggeeee 2222
SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333)))) IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo SSSSTTTTRRRReeeeaaaaddddIIIImmmmaaaaggggeeeeHHHHeeeeaaaaddddeeeerrrr((((3333))))
STEBADTAG Invalid TIFF tag.
STENOMEM Out of memory.
STEWRITETOREAD Attempt to write to a read only stream.
STESYSCALL System call failed.
STENEEDSEEK Operation requires seeking on a stream.
SSSSEEEEEEEE AAAALLLLSSSSOOOO
libstiff(3), STAddTag(3).
PPPPaaaaggggeeee 3333